﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FrameWork.Entity;
using Microsoft.ApplicationBlocks.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Data.Odbc;
using jmail;

namespace FrameWork.web.Code
{
    public class its_ServiceDocCs
    {
        public its_ServiceDocCs()
        {
            Microsoft.ApplicationBlocks.Data.SqlHelper.connectionString = ConfigurationManager.AppSettings["MsSql"].ToString();
        }

        /// <summary>
        ///发送短消息 
        /// </summary>
        /// <param name="Mobile">手机号</param>
        /// <param name="Msg">短消息内容</param>
        public void SendMessage(string Mobile, string  Msg)
        {
            string conStr = System.Configuration.ConfigurationManager.AppSettings["Oracle"];
            using (OdbcConnection oraConn = new OdbcConnection(conStr))
            {
                string strSQL = "INSERT INTO PJZB.SMS_SPICT_LIST (mobile, msg, task_status,msg_id) values('";
                strSQL += Mobile.Replace("'", "''").ToString().Trim() + "','";
                strSQL += Msg.Replace("'", "''").ToString().Trim() + "','WT', INFO_ID_SEQ.NEXTVAL)";

                OdbcCommand oraCmd;
                oraCmd = new OdbcCommand(strSQL, oraConn);
                oraConn.Open();
                oraCmd.ExecuteNonQuery();
                oraConn.Close();
            }
        }

        /*
        说明：sendEmail方法用来执行发送邮件功能，该方法无返回值。
        参数：sender表示发件人，senderuser表示发件人姓名，euser表示发件人的邮箱登录名，epwd表示发件人的邮箱密码，
           receiver表示收件人，subject表示邮件主题，body表示邮件内容，eserver表示发送邮件服务器。
        */
        /// <summary>
        /// sendEmail方法用来执行发送邮件功能，该方法无返回值。
        /// </summary>
        /// <param name="sender">发件人</param>
        /// <param name="senderuser">发件人姓名</param>
        /// <param name="euser">发件人的邮箱登录名</param>
        /// <param name="epwd">发件人的邮箱密码</param>
        /// <param name="receiver">收件人</param>
        /// <param name="subject">邮件主题</param>
        /// <param name="body">邮件内容</param>
        /// <param name="eserver">发送邮件服务器</param>
        public void sendEmail(string sender, string senderuser, string euser, string epwd, string receiver, string subject, string body, string eserver)
        {
            jmail.MessageClass jmMessage = new jmail.MessageClass();
            jmMessage.Charset = "GB2312";
            jmMessage.ISOEncodeHeaders = false;
            jmMessage.From = sender;
            jmMessage.FromName = senderuser;
            jmMessage.Subject = subject;
            jmMessage.MailServerUserName = euser;
            jmMessage.MailServerPassWord = epwd;
            jmMessage.AddRecipient(receiver, "", "");
            //不处理附件信息
            /*
            if (ddlAccessories.Items.Count > 0)
            {
                for (int i = 0; i < ddlAccessories.Items.Count; i++)
                {
                    string path = ddlAccessories.Items[i].Value;
                    jmMessage.AddAttachment(@path, true, "");
                }
            }*/
            jmMessage.Body = body;
            if (!jmMessage.Send(eserver, false))
            {
                Exception ex = new Exception("发送失败，请仔细检查邮件服务器或账户的设置是否正确!");
                throw ex;
            }
            jmMessage = null;
        }


        /// <summary>
        /// 添加服务单信息及首次派单信息
        /// </summary>
        /// <param name="_its_ServiceDoc"></param>

        public void its_ServiceDoc_Add(its_ServiceDoc _its_ServiceDoc, its_ServiceAllotDoc _its_ServiceAllotDoc)
        {
            SqlParameter[] sp = new SqlParameter[27]{
				new SqlParameter("@UID",SqlDbType.Int),
				new SqlParameter("@ServDocNo",SqlDbType.VarChar,20),
				new SqlParameter("@ServProbType",SqlDbType.Int),
				new SqlParameter("@ServTrobType",SqlDbType.Int),
				new SqlParameter("@RepUserNO",SqlDbType.VarChar,20),
				new SqlParameter("@RepUserName",SqlDbType.NVarChar,120),
				new SqlParameter("@RepDeptNo",SqlDbType.Int),
				new SqlParameter("@RepUserTel",SqlDbType.VarChar,50),
				new SqlParameter("@RepTitle",SqlDbType.NVarChar,200),
				new SqlParameter("@RepContent",SqlDbType.NText),
				new SqlParameter("@Accessories",SqlDbType.NVarChar,510),
				new SqlParameter("@Statue",SqlDbType.SmallInt),
				new SqlParameter("@AllotPSNID",SqlDbType.Int),
				new SqlParameter("@AllotNoticeType",SqlDbType.Int),
				new SqlParameter("@AttentPSNID",SqlDbType.Int),
				new SqlParameter("@AttentNoticeType",SqlDbType.Int),
				new SqlParameter("@HardwareInfo",SqlDbType.NText),
				new SqlParameter("@HardNoticeType",SqlDbType.Int),
				new SqlParameter("@IPAddressInfo",SqlDbType.NText),
				new SqlParameter("@IPNotifyType",SqlDbType.Int),
				new SqlParameter("@Solution",SqlDbType.NText),
				new SqlParameter("@Content",SqlDbType.NText),
				new SqlParameter("@Status",SqlDbType.SmallInt),
				new SqlParameter("@DealWith",SqlDbType.Bit),
				new SqlParameter("@DocDat",SqlDbType.DateTime),
				new SqlParameter("@DocSolvePSN",SqlDbType.Int),
                new SqlParameter("@DelegUID",SqlDbType.Int),
			
			};
           sp[0].Direction=ParameterDirection.Output;


            //
            if (_its_ServiceDoc.ServDocNo != "")
            {
                sp[1].Value = _its_ServiceDoc.ServDocNo;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServProbType != int.MinValue)
            {
                sp[2].Value = _its_ServiceDoc.ServProbType;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServTrobType != int.MinValue)
            {
                sp[3].Value = _its_ServiceDoc.ServTrobType;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepUserNO != "")
            {
                sp[4].Value = _its_ServiceDoc.RepUserNO;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepUserName != "")
            {
                sp[5].Value = _its_ServiceDoc.RepUserName;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepDeptNo != int.MinValue)
            {
                sp[6].Value = _its_ServiceDoc.RepDeptNo;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }

            sp[6].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepUserTel != "")
            {
                sp[7].Value = _its_ServiceDoc.RepUserTel;
            }
            else
            {
                sp[7].Value = DBNull.Value;
            }

            sp[7].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepTitle != "")
            {
                sp[8].Value = _its_ServiceDoc.RepTitle;
            }
            else
            {
                sp[8].Value = DBNull.Value;
            }

            sp[8].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepContent != "")
            {
                sp[9].Value = _its_ServiceDoc.RepContent;
            }
            else
            {
                sp[9].Value = DBNull.Value;
            }

            sp[9].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.Accessories != "")
            {
                sp[10].Value = _its_ServiceDoc.Accessories;
            }
            else
            {
                sp[10].Value = DBNull.Value;
            }

            sp[10].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.Statue != int.MinValue)
            {
                sp[11].Value = _its_ServiceDoc.Statue;
            }
            else
            {
                sp[11].Value = DBNull.Value;
            }

            sp[11].Direction = ParameterDirection.Input;

           
           //
			if(_its_ServiceAllotDoc.AllotPSNID != int.MinValue )
			{		
				sp[12].Value=_its_ServiceAllotDoc.AllotPSNID;			
			}
			else
			{
				sp[12].Value=DBNull.Value;
			}			

			sp[12].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.AllotNoticeType != int.MinValue )
			{		
				sp[13].Value=_its_ServiceAllotDoc.AllotNoticeType;			
			}
			else
			{
				sp[13].Value=DBNull.Value;
			}			

			sp[13].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.AttentPSNID != int.MinValue )
			{		
				sp[14].Value=_its_ServiceAllotDoc.AttentPSNID;			
			}
			else
			{
				sp[14].Value=DBNull.Value;
			}			

			sp[14].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.AttentNoticeType != int.MinValue )
			{		
				sp[15].Value=_its_ServiceAllotDoc.AttentNoticeType;			
			}
			else
			{
				sp[15].Value=DBNull.Value;
			}			

			sp[15].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.HardwareInfo != "")
			{		
				sp[16].Value=_its_ServiceAllotDoc.HardwareInfo;			
			}
			else
			{
				sp[16].Value=DBNull.Value;
			}			

			sp[16].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.HardNoticeType != int.MinValue )
			{		
				sp[17].Value=_its_ServiceAllotDoc.HardNoticeType;			
			}
			else
			{
				sp[17].Value=DBNull.Value;
			}			

			sp[17].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.IPAddressInfo != "")
			{		
				sp[18].Value=_its_ServiceAllotDoc.IPAddressInfo;			
			}
			else
			{
				sp[18].Value=DBNull.Value;
			}			

			sp[18].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.IPNotifyType != int.MinValue )
			{		
				sp[19].Value=_its_ServiceAllotDoc.IPNotifyType;			
			}
			else
			{
				sp[19].Value=DBNull.Value;
			}			

			sp[19].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.Solution != "")
			{		
				sp[20].Value=_its_ServiceAllotDoc.Solution;			
			}
			else
			{
				sp[20].Value=DBNull.Value;
			}			

			sp[20].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.Content != "")
			{		
				sp[21].Value=_its_ServiceAllotDoc.Content;			
			}
			else
			{
				sp[21].Value=DBNull.Value;
			}			

			sp[21].Direction=ParameterDirection.Input;


			//
			if(_its_ServiceAllotDoc.Status != int.MinValue )
			{		
				sp[22].Value=_its_ServiceAllotDoc.Status;			
			}
			else
			{
				sp[22].Value=DBNull.Value;
			}			

			sp[22].Direction=ParameterDirection.Input;


			//

			sp[23].Value=_its_ServiceAllotDoc.DealWith;			
			sp[23].Direction=ParameterDirection.Input;


            //
            if (_its_ServiceDoc.DocDat != DateTime.MinValue)
            {
                sp[24].Value = _its_ServiceDoc.DocDat;
            }
            else
            {
                sp[24].Value = DBNull.Value;
            }

            sp[24].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.DocSolvePSN != int.MinValue)
            {
                sp[25].Value = _its_ServiceDoc.DocSolvePSN;
            }
            else
            {
                sp[25].Value = DBNull.Value;
            }

            sp[26].Direction = ParameterDirection.Input;

            //
            if (_its_ServiceAllotDoc.DelegUID != int.MinValue)
            {
                sp[26].Value = _its_ServiceAllotDoc.DelegUID;
            }
            else
            {
                sp[26].Value = DBNull.Value;
            }

            sp[26].Direction = ParameterDirection.Input;

			try
			{
				SqlHelper.ExecuteDataset(CommandType.StoredProcedure,"dbo.its_ServiceDocAddFirst_Add",sp);
			}
			catch(Exception ex)
			{
				throw ex;
			}
        }

        /// <summary>
        /// 添加服务单信息及首次派单信息以及二次派单信息
        /// </summary>
        /// <param name="_its_ServiceDoc"></param>

        public void its_ServiceDoc_Add(its_ServiceDoc _its_ServiceDoc, its_ServiceAllotDoc _its_ServiceAllotDoc,its_ServiceAllotDoc _its_ServiceAllotDoc2)
        {
            SqlParameter[] sp = new SqlParameter[40]{
				new SqlParameter("@UID",SqlDbType.Int),
				new SqlParameter("@ServDocNo",SqlDbType.VarChar,20),
				new SqlParameter("@ServProbType",SqlDbType.Int),
				new SqlParameter("@ServTrobType",SqlDbType.Int),
				new SqlParameter("@RepUserNO",SqlDbType.VarChar,20),
				new SqlParameter("@RepUserName",SqlDbType.NVarChar,120),
				new SqlParameter("@RepDeptNo",SqlDbType.Int),
				new SqlParameter("@RepUserTel",SqlDbType.VarChar,50),
				new SqlParameter("@RepTitle",SqlDbType.NVarChar,200),
				new SqlParameter("@RepContent",SqlDbType.NText),
				new SqlParameter("@Accessories",SqlDbType.NVarChar,510),
				new SqlParameter("@Statue",SqlDbType.SmallInt),
				new SqlParameter("@AllotPSNID",SqlDbType.Int),
				new SqlParameter("@AllotNoticeType",SqlDbType.Int),
				new SqlParameter("@AttentPSNID",SqlDbType.Int),
				new SqlParameter("@AttentNoticeType",SqlDbType.Int),
				new SqlParameter("@HardwareInfo",SqlDbType.NText),
				new SqlParameter("@HardNoticeType",SqlDbType.Int),
				new SqlParameter("@IPAddressInfo",SqlDbType.NText),
				new SqlParameter("@IPNotifyType",SqlDbType.Int),
				new SqlParameter("@Solution",SqlDbType.NText),
				new SqlParameter("@Content",SqlDbType.NText),
				new SqlParameter("@Status",SqlDbType.SmallInt),
				new SqlParameter("@DealWith",SqlDbType.Bit),
				new SqlParameter("@AllotPSNID2",SqlDbType.Int),
				new SqlParameter("@AllotNoticeType2",SqlDbType.Int),
				new SqlParameter("@AttentPSNID2",SqlDbType.Int),
				new SqlParameter("@AttentNoticeType2",SqlDbType.Int),
				new SqlParameter("@HardwareInfo2",SqlDbType.NText),
				new SqlParameter("@HardNoticeType2",SqlDbType.Int),
				new SqlParameter("@IPAddressInfo2",SqlDbType.NText),
				new SqlParameter("@IPNotifyType2",SqlDbType.Int),
				new SqlParameter("@Solution2",SqlDbType.NText),
				new SqlParameter("@Content2",SqlDbType.NText),
				new SqlParameter("@Status2",SqlDbType.SmallInt),
				new SqlParameter("@DealWith2",SqlDbType.Bit),
				new SqlParameter("@DocDat",SqlDbType.DateTime),
				new SqlParameter("@DocSolvePSN",SqlDbType.Int),
                new SqlParameter("@DelegUID",SqlDbType.Int),
                new SqlParameter("@DelegUID2",SqlDbType.Int),
			
			};
            sp[0].Direction = ParameterDirection.Output;


            //
            if (_its_ServiceDoc.ServDocNo != "")
            {
                sp[1].Value = _its_ServiceDoc.ServDocNo;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServProbType != int.MinValue)
            {
                sp[2].Value = _its_ServiceDoc.ServProbType;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServTrobType != int.MinValue)
            {
                sp[3].Value = _its_ServiceDoc.ServTrobType;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepUserNO != "")
            {
                sp[4].Value = _its_ServiceDoc.RepUserNO;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepUserName != "")
            {
                sp[5].Value = _its_ServiceDoc.RepUserName;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepDeptNo != int.MinValue)
            {
                sp[6].Value = _its_ServiceDoc.RepDeptNo;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }

            sp[6].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepUserTel != "")
            {
                sp[7].Value = _its_ServiceDoc.RepUserTel;
            }
            else
            {
                sp[7].Value = DBNull.Value;
            }

            sp[7].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepTitle != "")
            {
                sp[8].Value = _its_ServiceDoc.RepTitle;
            }
            else
            {
                sp[8].Value = DBNull.Value;
            }

            sp[8].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.RepContent != "")
            {
                sp[9].Value = _its_ServiceDoc.RepContent;
            }
            else
            {
                sp[9].Value = DBNull.Value;
            }

            sp[9].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.Accessories != "")
            {
                sp[10].Value = _its_ServiceDoc.Accessories;
            }
            else
            {
                sp[10].Value = DBNull.Value;
            }

            sp[10].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.Statue != int.MinValue)
            {
                sp[11].Value = _its_ServiceDoc.Statue;
            }
            else
            {
                sp[11].Value = DBNull.Value;
            }

            sp[11].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AllotPSNID != int.MinValue)
            {
                sp[12].Value = _its_ServiceAllotDoc.AllotPSNID;
            }
            else
            {
                sp[12].Value = DBNull.Value;
            }

            sp[12].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AllotNoticeType != int.MinValue)
            {
                sp[13].Value = _its_ServiceAllotDoc.AllotNoticeType;
            }
            else
            {
                sp[13].Value = DBNull.Value;
            }

            sp[13].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AttentPSNID != int.MinValue)
            {
                sp[14].Value = _its_ServiceAllotDoc.AttentPSNID;
            }
            else
            {
                sp[14].Value = DBNull.Value;
            }

            sp[14].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AttentNoticeType != int.MinValue)
            {
                sp[15].Value = _its_ServiceAllotDoc.AttentNoticeType;
            }
            else
            {
                sp[15].Value = DBNull.Value;
            }

            sp[15].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.HardwareInfo != "")
            {
                sp[16].Value = _its_ServiceAllotDoc.HardwareInfo;
            }
            else
            {
                sp[16].Value = DBNull.Value;
            }

            sp[16].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.HardNoticeType != int.MinValue)
            {
                sp[17].Value = _its_ServiceAllotDoc.HardNoticeType;
            }
            else
            {
                sp[17].Value = DBNull.Value;
            }

            sp[17].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.IPAddressInfo != "")
            {
                sp[18].Value = _its_ServiceAllotDoc.IPAddressInfo;
            }
            else
            {
                sp[18].Value = DBNull.Value;
            }

            sp[18].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.IPNotifyType != int.MinValue)
            {
                sp[19].Value = _its_ServiceAllotDoc.IPNotifyType;
            }
            else
            {
                sp[19].Value = DBNull.Value;
            }

            sp[19].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Solution != "")
            {
                sp[20].Value = _its_ServiceAllotDoc.Solution;
            }
            else
            {
                sp[20].Value = DBNull.Value;
            }

            sp[20].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Content != "")
            {
                sp[21].Value = _its_ServiceAllotDoc.Content;
            }
            else
            {
                sp[21].Value = DBNull.Value;
            }

            sp[21].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Status != int.MinValue)
            {
                sp[22].Value = _its_ServiceAllotDoc.Status;
            }
            else
            {
                sp[22].Value = DBNull.Value;
            }

            sp[22].Direction = ParameterDirection.Input;


            //

            sp[23].Value = _its_ServiceAllotDoc.DealWith;
            sp[23].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.AllotPSNID != int.MinValue)
            {
                sp[24].Value = _its_ServiceAllotDoc2.AllotPSNID;
            }
            else
            {
                sp[24].Value = DBNull.Value;
            }

            sp[24].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.AllotNoticeType != int.MinValue)
            {
                sp[25].Value = _its_ServiceAllotDoc2.AllotNoticeType;
            }
            else
            {
                sp[25].Value = DBNull.Value;
            }

            sp[25].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.AttentPSNID != int.MinValue)
            {
                sp[26].Value = _its_ServiceAllotDoc2.AttentPSNID;
            }
            else
            {
                sp[26].Value = DBNull.Value;
            }

            sp[26].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.AttentNoticeType != int.MinValue)
            {
                sp[27].Value = _its_ServiceAllotDoc2.AttentNoticeType;
            }
            else
            {
                sp[27].Value = DBNull.Value;
            }

            sp[27].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.HardwareInfo != "")
            {
                sp[28].Value = _its_ServiceAllotDoc2.HardwareInfo;
            }
            else
            {
                sp[28].Value = DBNull.Value;
            }

            sp[28].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.HardNoticeType != int.MinValue)
            {
                sp[29].Value = _its_ServiceAllotDoc2.HardNoticeType;
            }
            else
            {
                sp[29].Value = DBNull.Value;
            }

            sp[29].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.IPAddressInfo != "")
            {
                sp[30].Value = _its_ServiceAllotDoc2.IPAddressInfo;
            }
            else
            {
                sp[30].Value = DBNull.Value;
            }

            sp[30].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.IPNotifyType != int.MinValue)
            {
                sp[31].Value = _its_ServiceAllotDoc2.IPNotifyType;
            }
            else
            {
                sp[31].Value = DBNull.Value;
            }

            sp[31].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.Solution != "")
            {
                sp[32].Value = _its_ServiceAllotDoc2.Solution;
            }
            else
            {
                sp[32].Value = DBNull.Value;
            }

            sp[32].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.Content != "")
            {
                sp[33].Value = _its_ServiceAllotDoc2.Content;
            }
            else
            {
                sp[33].Value = DBNull.Value;
            }

            sp[33].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc2.Status != int.MinValue)
            {
                sp[34].Value = _its_ServiceAllotDoc2.Status; 
            }
            else
            {
                sp[34].Value = DBNull.Value;
            }

            sp[34].Direction = ParameterDirection.Input;


            //

            sp[35].Value = _its_ServiceAllotDoc2.DealWith; 
            sp[35].Direction = ParameterDirection.Input;

            //
            if (_its_ServiceDoc.DocDat != DateTime.MinValue)
            {
                sp[36].Value = _its_ServiceDoc.DocDat;
            }
            else
            {
                sp[36].Value = DBNull.Value;
            }

            sp[36].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.DocSolvePSN != int.MinValue)
            {
                sp[37].Value = _its_ServiceDoc.DocSolvePSN;
            }
            else
            {
                sp[37].Value = DBNull.Value;
            }

            sp[38].Direction = ParameterDirection.Input;

            //
            if (_its_ServiceAllotDoc.DelegUID != int.MinValue)
            {
                sp[38].Value = _its_ServiceAllotDoc.DelegUID;
            }
            else
            {
                sp[38].Value = DBNull.Value;
            }

            sp[38].Direction = ParameterDirection.Input;

            //
            if (_its_ServiceAllotDoc2.DelegUID != int.MinValue)
            {
                sp[39].Value = _its_ServiceAllotDoc2.DelegUID;
            }
            else
            {
                sp[39].Value = DBNull.Value;
            }

            sp[39].Direction = ParameterDirection.Input;


            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceDocAddFirstSecond_Add", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 得到服务单号
        /// </summary>
        /// <param name="_its_DocNoTable"></param>
        /// <returns></returns>
        public string GetDocNo(its_DocNoTable _its_DocNoTable)
        {
            SqlParameter[] sp = new SqlParameter[1]{
				new SqlParameter("@DocNO",SqlDbType.VarChar,12),
			
			};
            //
            sp[0].Direction = ParameterDirection.Output;

            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.ITS_GetDocNo", sp);
                return sp[0].Value.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        /// <summary>
        /// --未解决服务单查询
        /// 返回为list,list[0]为总记录数,list[1]为查询结果        ///
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="_sys_User"></param>
        /// <returns></returns>
        public ArrayList its_unsolveServiceDoc(int PageSize, int PageIndex, sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[4]{
				new SqlParameter("@PageSize",SqlDbType.Int),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = PageSize;
            sp[0].Direction = ParameterDirection.Input;



            sp[1].Value = PageIndex;
            sp[1].Direction = ParameterDirection.Input;


            //

            sp[2].Value = _sys_User.UserID;
            sp[2].Direction = ParameterDirection.Input;

            //
            sp[3].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_unsolveServiceDoc", sp);
                DataTable dt = ds.Tables[0];
                ArrayList list = new ArrayList();
                list.Add((int)sp[3].Value);
                list.Add(dt);
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 返回未解决服务单记录数量
        /// </summary>
        /// <param name="_sys_User"></param>
        /// <returns></returns>
        public int its_unsolveServiceDoc_Count(sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[2]{
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = _sys_User.UserID;
            sp[0].Direction = ParameterDirection.Input;


            //
            sp[1].Direction = ParameterDirection.Output;

            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_unsolveServiceDoc_Count", sp);
                return (int)sp[1].Value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// --已解决服务单查询
        /// 返回为list,list[0]为总记录数,list[1]为查询结果        ///
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="_sys_User"></param>
        /// <returns></returns>
        public ArrayList its_solveServiceDoc(int PageSize, int PageIndex, sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[4]{
				new SqlParameter("@PageSize",SqlDbType.Int),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = PageSize;
            sp[0].Direction = ParameterDirection.Input;



            sp[1].Value = PageIndex;
            sp[1].Direction = ParameterDirection.Input;


            //

            sp[2].Value = _sys_User.UserID;
            sp[2].Direction = ParameterDirection.Input;

            //
            sp[3].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_solveServiceDoc", sp);
                DataTable dt = ds.Tables[0];
                ArrayList list = new ArrayList();
                list.Add((int)sp[3].Value);
                list.Add(dt);
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 已经解决问题单记录数
        /// </summary>
        /// <param name="_sys_User"></param>
        /// <returns></returns>

        public int its_solveServiceDoc_Count(sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[2]{
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = _sys_User.UserID;
            sp[0].Direction = ParameterDirection.Input;


            //
            sp[1].Direction = ParameterDirection.Output;

            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_solveServiceDoc_Count", sp);
                return (int)sp[1].Value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



        /// <summary>
        /// --参与已解决服务单查询
        /// 返回为list,list[0]为总记录数,list[1]为查询结果        ///
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="_sys_User"></param>
        /// <returns></returns>
        public ArrayList its_AttachSolveServiceDoc(int PageSize, int PageIndex, sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[4]{
				new SqlParameter("@PageSize",SqlDbType.Int),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = PageSize;
            sp[0].Direction = ParameterDirection.Input;



            sp[1].Value = PageIndex;
            sp[1].Direction = ParameterDirection.Input;


            //

            sp[2].Value = _sys_User.UserID;
            sp[2].Direction = ParameterDirection.Input;

            //
            sp[3].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_AttachSolveServiceDoc", sp);
                DataTable dt = ds.Tables[0];
                ArrayList list = new ArrayList();
                list.Add((int)sp[3].Value);
                list.Add(dt);
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// --参与未解决服务单查询
        /// 返回为list,list[0]为总记录数,list[1]为查询结果        ///
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="_sys_User"></param>
        /// <returns></returns>
        public ArrayList its_AttachUnSolveServiceDoc(int PageSize, int PageIndex, sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[4]{
				new SqlParameter("@PageSize",SqlDbType.Int),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = PageSize;
            sp[0].Direction = ParameterDirection.Input;



            sp[1].Value = PageIndex;
            sp[1].Direction = ParameterDirection.Input;


            //

            sp[2].Value = _sys_User.UserID;
            sp[2].Direction = ParameterDirection.Input;

            //
            sp[3].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_AttachUnSolveServiceDoc", sp);
                DataTable dt = ds.Tables[0];
                ArrayList list = new ArrayList();
                list.Add((int)sp[3].Value);
                list.Add(dt);
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 返回我关注服务单的记录数
        /// </summary>
        /// <param name="_sys_User"></param>
        public int its_AttentServiceDoc_Count(sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[2]{
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = _sys_User.UserID;
            sp[0].Direction = ParameterDirection.Input;


            //
            sp[1].Direction = ParameterDirection.Output;

            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_AttentServiceDoc_Count", sp);
                return (int)sp[1].Value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// --我关注的服务单查询
        /// 返回为list,list[0]为总记录数,list[1]为查询结果        ///
        /// </summary>
        /// <param name="PageSize"></param>
        /// <param name="PageIndex"></param>
        /// <param name="_sys_User"></param>
        /// <returns></returns>
        public ArrayList its_AttendServiceDoc(int PageSize, int PageIndex, sys_User _sys_User)
        {
            SqlParameter[] sp = new SqlParameter[4]{
				new SqlParameter("@PageSize",SqlDbType.Int),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@UserID",SqlDbType.NVarChar,20),
				new SqlParameter("@RecordCount",SqlDbType.Int),
			
			};
            //

            sp[0].Value = PageSize;
            sp[0].Direction = ParameterDirection.Input;



            sp[1].Value = PageIndex;
            sp[1].Direction = ParameterDirection.Input;


            //

            sp[2].Value = _sys_User.UserID;
            sp[2].Direction = ParameterDirection.Input;

            //
            sp[3].Direction = ParameterDirection.Output;
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_AttentServiceDoc", sp);
                DataTable dt = ds.Tables[0];
                ArrayList list = new ArrayList();
                list.Add((int)sp[3].Value);
                list.Add(dt);
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        /// <summary>
        /// 查询服务单信息
        /// </summary>
        /// <param name="_its_ServiceDoc"></param>
        /// <returns></returns>
        public DataTable ServiceSelect(its_ServiceDoc _its_ServiceDoc)
        {
            SqlParameter[] sp = new SqlParameter[1]{
				new SqlParameter("@ServDocNo",SqlDbType.NVarChar,20),
			
			};
            //

            sp[0].Value = _its_ServiceDoc.ServDocNo;
            sp[0].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceSelect", sp);
                DataTable dt = ds.Tables[0];
                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 结单
        /// </summary>
        /// <param name="_its_ServiceDoc"></param>
        public void Service_Finish(its_ServiceDoc _its_ServiceDoc, its_ServiceAllotDoc _its_ServiceAllotDoc)
        {
            SqlParameter[] sp = new SqlParameter[14]{
				new SqlParameter("@ServDocNo",SqlDbType.VarChar,20),
				new SqlParameter("@Statue",SqlDbType.SmallInt),
				new SqlParameter("@DocSolvePSN",SqlDbType.Int),
				new SqlParameter("@UID",SqlDbType.Int),
				new SqlParameter("@HardwareInfo",SqlDbType.NText),
				new SqlParameter("@HardNoticeType",SqlDbType.Int),
				new SqlParameter("@IPAddressInfo",SqlDbType.NText),
				new SqlParameter("@IPNotifyType",SqlDbType.Int),
				new SqlParameter("@Solution",SqlDbType.NText),
				new SqlParameter("@Content",SqlDbType.NText),
				new SqlParameter("@DealWith",SqlDbType.Bit),
                new SqlParameter("@DelegUID",SqlDbType.Bit),
				new SqlParameter("@ServProbType",SqlDbType.Int),
				new SqlParameter("@ServTrobType",SqlDbType.Int),
			
			};
            //
            if (_its_ServiceDoc.ServDocNo != "")
            {
                sp[0].Value = _its_ServiceDoc.ServDocNo;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.Statue != int.MinValue)
            {
                sp[1].Value = _its_ServiceDoc.Statue;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.DocSolvePSN != int.MinValue)
            {
                sp[2].Value = _its_ServiceDoc.DocSolvePSN;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.UID != int.MinValue)
            {
                sp[3].Value = _its_ServiceAllotDoc.UID;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.HardwareInfo != "")
            {
                sp[4].Value = _its_ServiceAllotDoc.HardwareInfo;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.HardNoticeType != int.MinValue)
            {
                sp[5].Value = _its_ServiceAllotDoc.HardNoticeType;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.IPAddressInfo != "")
            {
                sp[6].Value = _its_ServiceAllotDoc.IPAddressInfo;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }

            sp[6].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.IPNotifyType != int.MinValue)
            {
                sp[7].Value = _its_ServiceAllotDoc.IPNotifyType;
            }
            else
            {
                sp[7].Value = DBNull.Value;
            }

            sp[7].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Solution != "")
            {
                sp[8].Value = _its_ServiceAllotDoc.Solution;
            }
            else
            {
                sp[8].Value = DBNull.Value;
            }

            sp[8].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Content != "")
            {
                sp[9].Value = _its_ServiceAllotDoc.Content;
            }
            else
            {
                sp[9].Value = DBNull.Value;
            }

            sp[9].Direction = ParameterDirection.Input;


            //

            sp[10].Value = _its_ServiceAllotDoc.DealWith;
            sp[10].Direction = ParameterDirection.Input;

            //
            if (_its_ServiceAllotDoc.DelegUID != int.MinValue)
            {
                sp[11].Value = _its_ServiceAllotDoc.DelegUID;
            }
            else
            {
                sp[11].Value = DBNull.Value;
            }

            sp[11].Direction = ParameterDirection.Input;


            //

            sp[12].Value = _its_ServiceDoc.ServProbType;
            sp[12].Direction = ParameterDirection.Input;


            //

            sp[13].Value = _its_ServiceDoc.ServTrobType;
            sp[13].Direction = ParameterDirection.Input;


            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_Service_Finish", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 添加二次派单
        /// </summary>
        /// <param name="_its_ServiceAllotDoc"></param>
        public void ServiceAllotDoc_Add(its_ServiceDoc _its_ServiceDoc,its_ServiceAllotDoc _its_ServiceAllotDoc,its_ServiceAllotDoc _its_Old_ServiceAllotDoc)
        {
            SqlParameter[] sp = new SqlParameter[28]{
				new SqlParameter("@DOCNO",SqlDbType.VarChar,20),
				new SqlParameter("@AllotPSNID",SqlDbType.Int),
				new SqlParameter("@AllotNoticeType",SqlDbType.Int),
				new SqlParameter("@AttentPSNID",SqlDbType.Int),
				new SqlParameter("@AttentNoticeType",SqlDbType.Int),
				new SqlParameter("@HardwareInfo",SqlDbType.NText),
				new SqlParameter("@HardNoticeType",SqlDbType.Int),
				new SqlParameter("@IPAddressInfo",SqlDbType.NText),
				new SqlParameter("@IPNotifyType",SqlDbType.Int),
				new SqlParameter("@Solution",SqlDbType.NText),
				new SqlParameter("@Content",SqlDbType.NText),
				new SqlParameter("@Status",SqlDbType.SmallInt),
				new SqlParameter("@DealWith",SqlDbType.Bit),
				new SqlParameter("@DelegUID",SqlDbType.Int),
				new SqlParameter("@ServDocNo",SqlDbType.VarChar,20),
				new SqlParameter("@Statue",SqlDbType.SmallInt),
				new SqlParameter("@DocSolvePSN",SqlDbType.Int),
				new SqlParameter("@ServProbType",SqlDbType.Int),
				new SqlParameter("@ServTrobType",SqlDbType.Int),
				new SqlParameter("@OldUID",SqlDbType.Int),
				new SqlParameter("@OldHardwareInfo",SqlDbType.NText),
				new SqlParameter("@OldHardNoticeType",SqlDbType.Int),
				new SqlParameter("@OldIPAddressInfo",SqlDbType.NText),
				new SqlParameter("@OldIPNotifyType",SqlDbType.Int),
				new SqlParameter("@OldSolution",SqlDbType.NText),
				new SqlParameter("@OldContent",SqlDbType.NText),
				new SqlParameter("@OldDealWith",SqlDbType.Bit),
				new SqlParameter("@OldDelegUID",SqlDbType.Int),
			
			};
            //
            if (_its_ServiceAllotDoc.DOCNO != "")
            {
                sp[0].Value = _its_ServiceAllotDoc.DOCNO;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AllotPSNID != int.MinValue)
            {
                sp[1].Value = _its_ServiceAllotDoc.AllotPSNID;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AllotNoticeType != int.MinValue)
            {
                sp[2].Value = _its_ServiceAllotDoc.AllotNoticeType;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AttentPSNID != int.MinValue)
            {
                sp[3].Value = _its_ServiceAllotDoc.AttentPSNID;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.AttentNoticeType != int.MinValue)
            {
                sp[4].Value = _its_ServiceAllotDoc.AttentNoticeType;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.HardwareInfo != "")
            {
                sp[5].Value = _its_ServiceAllotDoc.HardwareInfo;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.HardNoticeType != int.MinValue)
            {
                sp[6].Value = _its_ServiceAllotDoc.HardNoticeType;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }

            sp[6].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.IPAddressInfo != "")
            {
                sp[7].Value = _its_ServiceAllotDoc.IPAddressInfo;
            }
            else
            {
                sp[7].Value = DBNull.Value;
            }

            sp[7].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.IPNotifyType != int.MinValue)
            {
                sp[8].Value = _its_ServiceAllotDoc.IPNotifyType;
            }
            else
            {
                sp[8].Value = DBNull.Value;
            }

            sp[8].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Solution != "")
            {
                sp[9].Value = _its_ServiceAllotDoc.Solution;
            }
            else
            {
                sp[9].Value = DBNull.Value;
            }

            sp[9].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Content != "")
            {
                sp[10].Value = _its_ServiceAllotDoc.Content;
            }
            else
            {
                sp[10].Value = DBNull.Value;
            }

            sp[10].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.Status != int.MinValue)
            {
                sp[11].Value = _its_ServiceAllotDoc.Status;
            }
            else
            {
                sp[11].Value = DBNull.Value;
            }

            sp[11].Direction = ParameterDirection.Input;


            //

            sp[12].Value = _its_ServiceAllotDoc.DealWith;
            sp[12].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceAllotDoc.DelegUID != int.MinValue)
            {
                sp[13].Value = _its_ServiceAllotDoc.DelegUID;
            }
            else
            {
                sp[13].Value = DBNull.Value;
            }

            sp[13].Direction = ParameterDirection.Input;
            //
            if (_its_ServiceDoc.ServDocNo != "")
            {
                sp[14].Value = _its_ServiceDoc.ServDocNo;
            }
            else
            {
                sp[14].Value = DBNull.Value;
            }

            sp[14].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.Statue != int.MinValue)
            {
                sp[15].Value = _its_ServiceDoc.Statue;
            }
            else
            {
                sp[15].Value = DBNull.Value;
            }

            sp[15].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.DocSolvePSN != int.MinValue)
            {
                sp[16].Value = _its_ServiceDoc.DocSolvePSN;
            }
            else
            {
                sp[16].Value = DBNull.Value;
            }

            sp[16].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServProbType != int.MinValue)
            {
                sp[17].Value = _its_ServiceDoc.ServProbType;
            }
            else
            {
                sp[17].Value = DBNull.Value;
            }

            sp[17].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServTrobType != int.MinValue)
            {
                sp[18].Value = _its_ServiceDoc.ServTrobType;
            }
            else
            {
                sp[18].Value = DBNull.Value;
            }

            sp[18].Direction = ParameterDirection.Input;



            //
            if (_its_Old_ServiceAllotDoc.UID != int.MinValue)
            {
                sp[19].Value = _its_Old_ServiceAllotDoc.UID;
            }
            else
            {
                sp[19].Value = DBNull.Value;
            }

            sp[19].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.HardwareInfo != "")
            {
                sp[20].Value = _its_Old_ServiceAllotDoc.HardwareInfo;
            }
            else
            {
                sp[20].Value = DBNull.Value;
            }

            sp[20].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.HardNoticeType != int.MinValue)
            {
                sp[21].Value = _its_Old_ServiceAllotDoc.HardNoticeType;
            }
            else
            {
                sp[21].Value = DBNull.Value;
            }

            sp[21].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.IPAddressInfo != "")
            {
                sp[22].Value = _its_Old_ServiceAllotDoc.IPAddressInfo;
            }
            else
            {
                sp[22].Value = DBNull.Value;
            }

            sp[22].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.IPNotifyType != int.MinValue)
            {
                sp[23].Value = _its_Old_ServiceAllotDoc.IPNotifyType;
            }
            else
            {
                sp[23].Value = DBNull.Value;
            }

            sp[23].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.Solution != "")
            {
                sp[24].Value = _its_Old_ServiceAllotDoc.Solution;
            }
            else
            {
                sp[24].Value = DBNull.Value;
            }

            sp[24].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.Content != "")
            {
                sp[25].Value = _its_Old_ServiceAllotDoc.Content;
            }
            else
            {
                sp[25].Value = DBNull.Value;
            }

            sp[25].Direction = ParameterDirection.Input;


            //

            sp[26].Value = _its_Old_ServiceAllotDoc.DealWith;
            sp[26].Direction = ParameterDirection.Input;


            //
            if (_its_Old_ServiceAllotDoc.DelegUID != int.MinValue)
            {
                sp[27].Value = _its_Old_ServiceAllotDoc.DelegUID;
            }
            else
            {
                sp[27].Value = DBNull.Value;
            }

            sp[27].Direction = ParameterDirection.Input;

            try
            {
                SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceAllotDoc_AddSecond", sp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 得到要发送邮件和短消息的人员
        /// </summary>
        /// <param name="bbb">“1,2,3”</param>
        /// <returns></returns>
        public DataTable GetEmailUser(string R_RoleID, string UserIDs)
        {
            SqlParameter[] sp = new SqlParameter[2]{
				new SqlParameter("@R_RoleID",SqlDbType.NVarChar,20),
				new SqlParameter("@UserIDs",SqlDbType.NVarChar,300),
			
			};
            //
            if (R_RoleID != "")
            {
                sp[0].Value = R_RoleID;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (UserIDs != "")
            {
                sp[1].Value = UserIDs;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_GetEmailUser", sp);
                DataTable dt = ds.Tables[0];
                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataTable GetDocDetail(string DocID)
        {
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.Text, "select * from its_ServiceAllotDoc where uid = '" + DocID + "'");
                DataTable dt = ds.Tables[0];
                return dt;
            }
            catch 
            {
                throw; 
            }
        }

        /// <summary>
        /// 发送邮件通知给相关人员
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="sender">发送邮件账户</param>
        /// <param name="eserver">发送邮件服务器</param>
        /// <param name="euser">发件人的邮箱登录名</param>
        /// <param name="epwd">发件人的邮箱密码</param>
        /// <param name="subject">邮件主题</param>
        /// <param name="body">发送邮件内容</param>
        public void SendMailTo(int userID, string sender, string eserver, string euser, string epwd, string subject, string body)
        {
            //发件人姓名
            string senderUser = "SPICT ITMS";
            DataTable dt = GetEmailUser("", userID.ToString());
            foreach (DataRow dr in dt.Rows)
            {
               string recMail = dr["U_CompanyMail"].ToString().Trim();
               if (recMail != "")
               {
                   sendEmail(sender, senderUser, euser, epwd, recMail, subject, body, eserver);
               }
            }

        }

        /// <summary>
        /// 发送邮件通知给PC管理员
        /// </summary>
        /// <param name="sender">发送邮件账户</param>
        /// <param name="eserver">发送邮件服务器</param>
        /// <param name="euser">发件人的邮箱登录名</param>
        /// <param name="epwd">发件人的邮箱密码</param>
        /// <param name="subject">邮件主题</param>
        /// <param name="body">发送邮件内容</param>
        public void SendMailToPCAdmin(string sender, string eserver, string euser, string epwd, string subject, string body)
        {
            string roleID = ConfigurationManager.AppSettings["pc_admin"];
            //发件人姓名
            string senderUser = "SPICT ITMS";
            DataTable dt = GetEmailUser(roleID,"");
            foreach (DataRow dr in dt.Rows)
            {
               string recMail = dr["U_CompanyMail"].ToString().Trim();
               if (recMail != "")
               {
                   sendEmail(sender, senderUser, euser, epwd, recMail, subject, body, eserver);
               }
            }
            //if (recMail.Substring(recMail.Length - 1, 1) == ",")
        }

        /// <summary>
        /// 发送邮件通知给硬件管理员
        /// </summary>
        /// <param name="sender">发送邮件账户</param>
        /// <param name="eserver">发送邮件服务器</param>
        /// <param name="euser">发件人的邮箱登录名</param>
        /// <param name="epwd">发件人的邮箱密码</param>
        /// <param name="subject">邮件主题</param>
        /// <param name="body">发送邮件内容</param>
        public void SendMailToHardwareAdmin(string sender, string eserver, string euser, string epwd, string subject, string body)
        {
            string roleID = ConfigurationManager.AppSettings["hardware_admin"];
            //发件人姓名
            string senderUser = "SPICT ITMS";
            DataTable dt = GetEmailUser(roleID, "");
            foreach (DataRow dr in dt.Rows)
            {
                string recMail = dr["U_CompanyMail"].ToString().Trim();
                if (recMail != "")
                {
                    sendEmail(sender, senderUser, euser, epwd, recMail, subject, body, eserver);
                }
            }
            //if (recMail.Substring(recMail.Length - 1, 1) == ",")
        }

        /// <summary>
        /// 发送短消息通知给相关人员
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="Msg">短信内容</param>
        public void SendMsgTo(int userID, string Msg)
        {
            DataTable dt = GetEmailUser("", userID.ToString());
            foreach (DataRow dr in dt.Rows)
            {
                string Mobile = dr["U_MobileNo"].ToString().Trim();
                if ((Msg.Trim() != "") && (Msg.Trim().Length < 100) && (Mobile != ""))
                {
                    SendMessage(Mobile, Msg);

                }
            }
        }

        /// <summary>
        /// 发送短消息通知PC管理员
        /// </summary>
        /// <param name="Msg"></param>
        public void SendMsgToPCAdmin(string Msg)
        {
            string roleID = ConfigurationManager.AppSettings["pc_admin"];
            DataTable dt = GetEmailUser(roleID.ToString(), "");
            foreach (DataRow dr in dt.Rows)
            {
                string Mobile = dr["U_MobileNo"].ToString().Trim();

                if ((Msg.Trim() != "") && (Msg.Trim().Length < 100) && (Mobile != ""))
                {
                    SendMessage(Mobile, Msg);

                }
            }
        }

        /// <summary>
        /// 发送短消息通知PC管理员
        /// </summary>
        /// <param name="Msg"></param>
        public void SendMsgToHardWareAdmin(string Msg)
        {
            string roleID = ConfigurationManager.AppSettings["hardware_admin"];
            DataTable dt = GetEmailUser(roleID.ToString(), "");
            foreach (DataRow dr in dt.Rows)
            {
                string Mobile = dr["U_MobileNo"].ToString().Trim();

                if ((Msg.Trim() != "") && (Msg.Trim().Length < 100) && (Mobile != ""))
                {
                    SendMessage(Mobile, Msg);

                }
            }
        }

        /// <summary>
        /// 服务单查询
        /// </summary>
        /// <param name="RepUserNO">报修人工号</param>
        /// <param name="RepUserName">报修人姓名</param>
        /// <param name="DocSolvePSNNo">解决人工号</param>
        /// <param name="DocSolvePSNName">解决人姓名</param>
        /// <param name="DocDatBegin">开始时间</param>
        /// <param name="DocDatEnd">结束时间</param>
        /// <param name="Statue">包括未解决的服务单</param>
        /// <param name="PageIndex">当前页</param>
        /// <param name="PageSize">每页大小</param>
        /// <returns></returns>
        public DataTable ServiceDoc_Select(string RepUserNO, string RepUserName, string DocSolvePSNNo, string DocSolvePSNName, string DocDatBegin, string DocDatEnd, bool Statue, int PageIndex, int PageSize)
        {
            SqlParameter[] sp = new SqlParameter[9]{
				new SqlParameter("@RepUserNO",SqlDbType.VarChar,20),
				new SqlParameter("@RepUserName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocSolvePSNNo",SqlDbType.NVarChar,20),
				new SqlParameter("@DocSolvePSNName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocDatBegin",SqlDbType.NVarChar,50),
				new SqlParameter("@DocDatEnd",SqlDbType.NVarChar,50),
				new SqlParameter("@Statue",SqlDbType.Bit),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@PageSize",SqlDbType.Int),
			
			};
            //
            if (RepUserNO != "")
            {
                sp[0].Value = RepUserNO;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (RepUserName != "")
            {
                sp[1].Value = RepUserName;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNNo != "")
            {
                sp[2].Value = DocSolvePSNNo;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNName != "")
            {
                sp[3].Value = DocSolvePSNName;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (DocDatBegin != "")
            {
                sp[4].Value = DocDatBegin;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (DocDatEnd != "")
            {
                sp[5].Value = DocDatEnd;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (Statue)
            {
                sp[6].Value = 1;
            }
            else
            {
                sp[6].Value = 0;
            }
            sp[6].Direction = ParameterDirection.Input;


            //
            if (PageIndex != int.MinValue)
            {
                sp[7].Value = PageIndex;
            }
            else
            {
                sp[7].Value = DBNull.Value;
            }

            sp[7].Direction = ParameterDirection.Input;


            //
            if (PageSize != int.MinValue)
            {
                sp[8].Value = PageSize;
            }
            else
            {
                sp[8].Value = DBNull.Value;
            }

            sp[8].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceDoc_Select", sp);
                DataTable dt = ds.Tables[0];
                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        

        /// <summary>
        /// 服务单数量
        /// </summary>
        /// <param name="RepUserNO">报修人工号</param>
        /// <param name="RepUserName">报修人姓名</param>
        /// <param name="DocSolvePSNNo">解决人工号</param>
        /// <param name="DocSolvePSNName">解决人姓名</param>
        /// <param name="DocDatBegin">开始时间</param>
        /// <param name="DocDatEnd">结束时间</param>
        /// <param name="Statue">包括未解决的服务单</param>
        /// <returns></returns>
        public int ServiceDoc_SelectCount(string RepUserNO, string RepUserName, string DocSolvePSNNo, string DocSolvePSNName, string DocDatBegin, string DocDatEnd, bool Statue)
        {
            SqlParameter[] sp = new SqlParameter[7]{
				new SqlParameter("@RepUserNO",SqlDbType.VarChar,20),
				new SqlParameter("@RepUserName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocSolvePSNNo",SqlDbType.NVarChar,20),
				new SqlParameter("@DocSolvePSNName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocDatBegin",SqlDbType.NVarChar,50),
				new SqlParameter("@DocDatEnd",SqlDbType.NVarChar,50),
				new SqlParameter("@Statue",SqlDbType.Bit),
			
			};
            //
            if (RepUserNO != "")
            {
                sp[0].Value = RepUserNO;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (RepUserName != "")
            {
                sp[1].Value = RepUserName;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNNo != "")
            {
                sp[2].Value = DocSolvePSNNo;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNName != "")
            {
                sp[3].Value = DocSolvePSNName;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (DocDatBegin != "")
            {
                sp[4].Value = DocDatBegin;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (DocDatEnd != "")
            {
                sp[5].Value = DocDatEnd;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (Statue)
            {
                sp[6].Value = 1;
            }
            else
            {
                sp[6].Value = 0;
            }
            sp[6].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceDoc_Count", sp);
                DataTable dt = ds.Tables[0];
                return int.Parse(dt.Rows[0][0].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 在知识库归纳中查询服务单信息
        /// </summary>
        /// <param name="_its_ServiceDoc"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <returns>返回ArrayList,第一项为记录数，第二项为结果集</returns>
        /// 
        public ArrayList ServiceDoc_KnowledgeSelect(its_ServiceDoc _its_ServiceDoc, int PageIndex, int PageSize)
        {
            SqlParameter[] sp = new SqlParameter[6]{
				new SqlParameter("@Done",SqlDbType.Int),
				new SqlParameter("@ServTrobType",SqlDbType.Int),
				new SqlParameter("@ServProbType",SqlDbType.Int),
				new SqlParameter("@ServDocNo",SqlDbType.NVarChar,20),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@PageSize",SqlDbType.Int),
			
			};
            //
            if (_its_ServiceDoc.Done != -1)
            {
                sp[0].Value = _its_ServiceDoc.Done;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServTrobType != -1)
            {
                sp[1].Value = _its_ServiceDoc.ServTrobType;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServProbType != -1)
            {
                sp[2].Value = _its_ServiceDoc.ServProbType;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (_its_ServiceDoc.ServDocNo != "")
            {
                sp[3].Value = _its_ServiceDoc.ServDocNo;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //

            sp[4].Value = PageIndex;

            sp[4].Direction = ParameterDirection.Input;


            //

            sp[5].Value = PageSize;


            sp[5].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceDoc_KnowledgeSelect", sp);
                DataTable dt = ds.Tables[0];
                ArrayList arrRuselt = new ArrayList();
                arrRuselt.Add(int.Parse(ds.Tables[1].Rows[0][0].ToString()));
                arrRuselt.Add(dt);
                return arrRuselt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// 服务单批注查询
        /// </summary>
        /// <param name="RepUserNO">报修人工号</param>
        /// <param name="RepUserName">报修人姓名</param>
        /// <param name="DocSolvePSNNo">解决人工号</param>
        /// <param name="DocSolvePSNName">解决人姓名</param>
        /// <param name="DocDatBegin">开始时间</param>
        /// <param name="DocDatEnd">结束时间</param>
        /// <param name="Statue">批注</param>
        /// <param name="PageIndex">当前页</param>
        /// <param name="PageSize">每页大小</param>
        /// <returns></returns>
        public DataTable ServiceDoc_PostilSelect(string RepUserNO, string RepUserName, string DocSolvePSNNo, string DocSolvePSNName, string DocDatBegin, string DocDatEnd, int Statue, int PageIndex, int PageSize)
        {
            SqlParameter[] sp = new SqlParameter[9]{
				new SqlParameter("@RepUserNO",SqlDbType.VarChar,20),
				new SqlParameter("@RepUserName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocSolvePSNNo",SqlDbType.NVarChar,20),
				new SqlParameter("@DocSolvePSNName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocDatBegin",SqlDbType.NVarChar,50),
				new SqlParameter("@DocDatEnd",SqlDbType.NVarChar,50),
				new SqlParameter("@Statue",SqlDbType.Int),
				new SqlParameter("@PageIndex",SqlDbType.Int),
				new SqlParameter("@PageSize",SqlDbType.Int),
			
			};
            //
            if (RepUserNO != "")
            {
                sp[0].Value = RepUserNO;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (RepUserName != "")
            {
                sp[1].Value = RepUserName;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNNo != "")
            {
                sp[2].Value = DocSolvePSNNo;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNName != "")
            {
                sp[3].Value = DocSolvePSNName;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (DocDatBegin != "")
            {
                sp[4].Value = DocDatBegin;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (DocDatEnd != "")
            {
                sp[5].Value = DocDatEnd;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (Statue != -1)
            {
                sp[6].Value = Statue;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }
            sp[6].Direction = ParameterDirection.Input;


            //
            if (PageIndex != int.MinValue)
            {
                sp[7].Value = PageIndex;
            }
            else
            {
                sp[7].Value = DBNull.Value;
            }

            sp[7].Direction = ParameterDirection.Input;


            //
            if (PageSize != int.MinValue)
            {
                sp[8].Value = PageSize;
            }
            else
            {
                sp[8].Value = DBNull.Value;
            }

            sp[8].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServiceDoc_PostilSelect", sp);
                DataTable dt = ds.Tables[0];
                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        /// <summary>
        /// 服务单批注数量
        /// </summary>
        /// <param name="RepUserNO">报修人工号</param>
        /// <param name="RepUserName">报修人姓名</param>
        /// <param name="DocSolvePSNNo">解决人工号</param>
        /// <param name="DocSolvePSNName">解决人姓名</param>
        /// <param name="DocDatBegin">开始时间</param>
        /// <param name="DocDatEnd">结束时间</param>
        /// <param name="Statue">状态</param>
        /// <returns></returns>
        public int ServiceDoc_PostilSelectCount(string RepUserNO, string RepUserName, string DocSolvePSNNo, string DocSolvePSNName, string DocDatBegin, string DocDatEnd, int Statue)
        {
            SqlParameter[] sp = new SqlParameter[7]{
				new SqlParameter("@RepUserNO",SqlDbType.VarChar,20),
				new SqlParameter("@RepUserName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocSolvePSNNo",SqlDbType.NVarChar,20),
				new SqlParameter("@DocSolvePSNName",SqlDbType.NVarChar,60),
				new SqlParameter("@DocDatBegin",SqlDbType.NVarChar,50),
				new SqlParameter("@DocDatEnd",SqlDbType.NVarChar,50),
				new SqlParameter("@Statue",SqlDbType.Int),
			
			};
            //
            if (RepUserNO != "")
            {
                sp[0].Value = RepUserNO;
            }
            else
            {
                sp[0].Value = DBNull.Value;
            }

            sp[0].Direction = ParameterDirection.Input;


            //
            if (RepUserName != "")
            {
                sp[1].Value = RepUserName;
            }
            else
            {
                sp[1].Value = DBNull.Value;
            }

            sp[1].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNNo != "")
            {
                sp[2].Value = DocSolvePSNNo;
            }
            else
            {
                sp[2].Value = DBNull.Value;
            }

            sp[2].Direction = ParameterDirection.Input;


            //
            if (DocSolvePSNName != "")
            {
                sp[3].Value = DocSolvePSNName;
            }
            else
            {
                sp[3].Value = DBNull.Value;
            }

            sp[3].Direction = ParameterDirection.Input;


            //
            if (DocDatBegin != "")
            {
                sp[4].Value = DocDatBegin;
            }
            else
            {
                sp[4].Value = DBNull.Value;
            }

            sp[4].Direction = ParameterDirection.Input;


            //
            if (DocDatEnd != "")
            {
                sp[5].Value = DocDatEnd;
            }
            else
            {
                sp[5].Value = DBNull.Value;
            }

            sp[5].Direction = ParameterDirection.Input;


            //
            if (Statue != -1)
            {
                sp[6].Value = Statue;
            }
            else
            {
                sp[6].Value = DBNull.Value;
            }
            sp[6].Direction = ParameterDirection.Input;


            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(CommandType.StoredProcedure, "dbo.its_ServicePostisDoc_Count", sp);
                DataTable dt = ds.Tables[0];
                return int.Parse(dt.Rows[0][0].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
